package xyz.hlh.boot3.controller;

import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import xyz.hlh.boot3.service.GoodsService;

/**
 * @author HLH
 * @description: 商品控制层
 * @email 17703595860@163.com
 * @date : Created in 2021/10/30 21:07
 */
@Controller // 同步 使用thymeleaf模板引擎
public class GoodsController {

    // 注入dubbo服务
    @DubboReference(interfaceClass = GoodsService.class, version = "1.0")
    private GoodsService goodsService;
    // 注入dubbo服务
    @DubboReference(interfaceClass = GoodsService.class, version = "2.0")
    private GoodsService goodsService2;

    @GetMapping("/goods/list/1.0")
    public String toListOld(Model model) {
        model.addAttribute("goods", goodsService.getList());
        return "goods";
    }

    @GetMapping("/goods/list/2.0")
    public String toListNew(Model model) {
        model.addAttribute("goods", goodsService2.getList());
        return "goods";
    }

}
